<template>
  <div>
    <myNavbar title="分润记录"></myNavbar>
    <scroller>
      <div v-if="showDetail">
        <div class="saveCard-bottom pd-L20 pd-R20">
          <div class="detailed-content" v-if="detailedList.length > 0">
            <div class="detailed-box-content" v-for="(item,index) in detailedList">
              <div style="display:flex; justify-content: space-between;flex-direction: row">
                <div style="display:flex;flex-direction: row">
                  <image src="http://cdn.rzico.com/v4.0/wallet-consumption.png" style="height:60px;width:60px;margin-top:10px"></image>
                  <div class="detailed-title">
                    <div class="aaaaa">
                      <text class="detailed-name">{{item.memo}}</text>
                    </div>
                    <text class="detailed-date">{{item.createDate}}</text>
                  </div>
                </div>
                <div class="price-content">
                  <div style="display:flex;flex-direction: row;align-items:flex-end;justify-content: flex-end;height:40px;">
                    <text class="price" v-if="item.credit-item.debit>0" :class="[item.credit-item.debit>0?'reducePrice':'price']">+</text>
                    <text class="price" :class="[item.credit-item.debit>0?'reducePrice':'price']">{{(item.credit-item.debit)/100}}</text>
                  </div>
                  <div style="width:190px;display:flex;  align-items: flex-end;justify-content: flex-end;">
                    <text class="yue">余额:{{parseInt(item.balance/100)}}</text>
                  </div>
                  <div style="width:190px;display:flex;  align-items: flex-end;justify-content: flex-end;" v-if="item.type==3">
                    <text class="yue reducePrices"  v-if="item.status==0" >状态:待审核</text>
                    <text class="yue reducePrices"  v-if="item.status==1" >状态:已确认</text>
                    <text class="yue reducePrices"  v-if="item.status==2" >状态:已完成</text>
                    <text class="yue reducePrices"  v-if="item.status==3" >状态:已关闭</text>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="saveCard-none" v-else>
        <noData noDataText="暂无消费记录啊" ></noData>
      </div>
      <loading v-if="showDetail" class="loading" @loading="onloading" :display="loadinging ? 'show' : 'hide'">
        <text class="indicator-text">加载中...</text>
      </loading>
    </scroller>
  </div>


</template>
<script>
import myNavbar from "../../../components/myNavbar/myNavbar.vue";
import { list } from '@/api/point'
// import { list } from '@/api/stockDeposit'
import noData from '../../../components/noData/noData.vue'

export default {
  data(){
    return{
      showDetail: false,
      scrollData: [], //记录要滚动的数据
      loadinging: false,
      pageNum: 1,
      pageSize: 20,
      detailedList: [
        //     {
        //   balance: 1000000,
        //   createDate: 1630033868000,
        //   credit: 1000000,
        //   debit: 0,
        //   enterpriseId: 1,
        //   id: 11531,
        //   memberId: 2490,
        //   memo: "直推奖-会员:消费者1",
        //   orderId: 2290,
        //   orderType: 0,
        //   type: 0,
        // }
      ]
    }
  },
  components: { myNavbar,noData },
  mounted(){
    this.getdata();
  },
  methods:{
    getdata(){
      this.loadinging = true;
      if (this.pageNum == 1) {
        this.detailedList = []
      }
      list({
        pageSize: this.pageSize,
        pageNum: this.pageNum,
        type:4
      }).then(res => {
        res.data.data.forEach(item => {
          item.createDate = this.formatDate2Time(item.createDate)
          item.thumbnail = 'http://cdn.rzico.com/v4.0/wallet-consumption.png'
          this.detailedList.push(item)
        })
        if (this.detailedList.length>0){
          this.showDetail = true;
        }
        eeui.loadingClose();
        this.loadinging = false;
      })
    },
    // 触底加载
    onloading() {
      if (this.loadinging == false) {
        this.pageNum += 1;
        // modal.toast({ message: '加载中', duration: 1 });
        eeui.loading();
        this.getdata();
      }
    },





    formatDate2Time(val) {
      let date = new Date(val);
      let y = date.getFullYear();
      let MM = date.getMonth() + 1;
      MM = MM < 10 ? ('0' + MM) : MM;
      let d = date.getDate();
      d = d < 10 ? ('0' + d) : d;
      let h = date.getHours();
      h = h < 10 ? ('0' + h) : h;
      let m = date.getMinutes();
      m = m < 10 ? ('0' + m) : m;
      let s = date.getSeconds();
      s = s < 10 ? ('0' + s) : s;
      return y + '-' + MM + '-' + d + " " + h + ":" + m + ":" + s;
    },

    loadlist() {
      if (this.pageNum == 1) {
        this.detailedList = []
      }
      list({
        pageSize: this.pageSize,
        pageNum: this.pageNum
      }).then(res => {
        res.data.data.forEach(item => {
          item.createDate = this.formatDate2Time(item.createDate)
          item.thumbnail = 'http://cdn.rzico.com/v4.0/wallet-consumption.png'
          this.data.detailedList.push(item)
        })

        // this.setData({
        //   detailedList: this.data.detailedList
        // })
      })
    },



    // 上拉加载更多
    onPullDownRefresh() {
      wx.showNavigationBarLoading()
      this.data.pageNum = 1
      setTimeout(() => {
        wx.hideNavigationBarLoading()
        this.loadList()
        wx.stopPullDownRefresh()
      }, 1000);
    },

    onReachBottom() {
      this.data.pageNum += 1
      this.loadList()
    },
  }

}
</script>
<style>
page {
  background: rgb(248, 248, 248);
}

.vein {
  position: absolute;
  width: 100%;
}

.rule-content {
  z-index: 200;
  position: fixed;
  background-color: rgba(0, 0, 0, 0.5);
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
}

.rule-dio {
  display: flex;
  padding-top: 20px;
  flex-direction: column;
  align-items: center;
  height: 350px;
  width: 710px;
  background-color: white;
  border-radius: 16px;
}
.rule-text{
  height: 70px;
  width: 350px;
  display: flex;
  flex-direction: row;
  align-items: center;
  /* justify-content: center; */
}
.yue{
  font-size: 24px;
  font-family: PingFangSC;
  font-weight: 400;
  color: #1a1a1e;
  /*opacity: 0.3;*/
}
.rule-click {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  margin-top: 20px;
  height: 60px;
  width: 170px;
  background: linear-gradient(to right, #474747, #474747);
  color: #b19e81;
  border-radius: 14px;
}

.rule-title {
  color: #b19e81;

}

.deposit {
  width: 750px;
  height: 600px;
  background-image: linear-gradient(to bottom, #c2c2c2, #f8f8f8);

}
.price-content{
  /*display: flex;*/
  /*flex-direction: column;*/
  /*justify-content: space-between;*/
  /*height: 100%;*/
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.total-deposit {
  height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.total-deposit-head {
  width: 655px;
  padding-top: 30px;
  height: 105px;
  background: linear-gradient(to right, #f7dec5, #f0d0a7);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  padding-left: 20px;
  padding-right: 20px;
}

.total-deposit-bottom {
  height: 120px;
  background-color: white;
  width: 710px;
  padding-top: 20px;
  padding-left: 20px;
  padding-right: 20px;
}

.aaaa {
  width: 750px;
  height: 91px;
}

.total-deposit-money {
  width: 695px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}

.botton-deposit {
  padding-top: 20px;
  /* height: 260px; */
  background-color: white;
  padding: 20px;
  /* padding-bottom: 20px; */
}

.botton-deposit-title-content {
  height: 40px;
  width: 143px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}

.vertical {
  margin-top: 10px;
  height: 30px;
  width: 10px;
  background: linear-gradient(to bottom, #FFFFF0, #FFD39B);
}

.botton-deposit-title {
  font-size: 30px;
}

.botton-deposit-botton-content {
  display: flex;
  flex-direction: row;
  justify-content: space-around;

}

.title-button {
  margin-top: 10px;
  font-size: 28px;

}

.button-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  /* margin-top: 40px; */
  width: 200px;

}

.button {
  height: 120px;
  width: 120px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(to right, #f7dec5, #f0d0a7);
}

.title {
  margin-top: 10px;
  font-size: 28px;
  margin-left: 20px;
}

.detailed-content {
  padding-bottom: 20px;
  padding-top: 20px;
  margin-top: 30px;
  background-color: white;
  overflow-y: auto;
}

.detailed-title-content {
  width: 710px;
  padding-left: 20px;
  display: flex;
  flex-direction: row;
  margin-bottom: 40px;
  overflow: hidden;

}

.detailed-box-content {
  background-color: white;
  padding-right: 35px;
  padding-left: 35px;
  align-content: center;
  justify-content: space-between;
  height: 140px;
}

.detailed-title {
  margin-left: 20px;
  width: 400px;
  display: flex;
  flex-direction: column;

}
.aaaaa{
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 400px;
  max-height: 92px;
}
.detailed-name {
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  justify-content: space-between;
  font-size: 25px;
}

.detailed-date {
  margin-top: 10px;
  font-size: 25px;
  color: #808080;
}

.price {
  float: right;
  color: #FF6347;
  font-weight: 700;
  font-size: 27px;
}
.reducePrice{
  float: right;
  color: black;
  font-weight: 700;
  font-size: 27px;
}
.reducePrices{
  float: right;
  color: #FF6347;
  /*color: red;*/
  /*font-size: 27px;*/
}
.invitation-button {

  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  background-color: #333333;
  color: #ffffde;
  font-size: 30px;
  border-radius: 20px;
}

.header {
  height: 146px;
  padding-right: 47px;
  padding-left: 30px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}

.header-info {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  margin-bottom: 20px;
}


.rule {
  z-index: 100;
  width: 170px;
  height: 50px;
  border-radius: 20px;
  opacity: 0.8;
  display: flex;
  flex-direction: row;
  justify-content:space-evenly;
  align-items: center;
  font-size: 25px;
}

.rule-circular {
  height: 30px;
  width: 30px;
  border: 4px solid;
  color: black;
  border-radius: 50px;
  font-size: 20px;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
}

.isMaskCanvas {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.cancelCanvasBotton {
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  color: white;
  font-size: 40px;
  width: 440px;
  margin-bottom: 20px;
}


.poste_content {
  width: 440px;
  /* margin: auto; */
  overflow: hidden;
  /* margin-top: 200px; */
  /* background-color: #fff; */
  /* position: absolute;
  top: 0; */
  z-index: 9999;
  border-radius: 16px;
}
.canvasBotton {
  border: 2px solid white;
  padding: 10px 100px;
  border-radius: 100px;
  margin-top: 40px;
}
.canvasBottonTitle {
  font-size: 28px;
  color: white;
}
.indicator-text {
  color: #888888;
  font-size: 22px;
  text-align: center;
  padding-top: 20px;
}

</style>

